<?php
//$data["sEcho"]=$_POST['sEcho'];
//$data["iDisplayStart"]=$_POST['iDisplayStart'];
//

//$data["iTotalRecords"]=57;
//$data["iTotalDisplayRecords"]=57;
////for ($i = 1; $i <= $_POST["iDisplayLength"]; $i++) {
//for ($i = 1; $i <= $_POST["iDisplayLength"]; $i++) {    
//    if ($i%2 == 0){
//        $dat='2012-12-15';
//    }else{
//        $dat='2012-12-16';
//    }    
//    $data["aaData"][]=array(
//        $i,
//        $dat,
//        "2013-12-2".rand(0,9),
//        "2013-12-2".rand(0,9),
//        "10".rand(0,9),
//        "Type-".rand(0,9),
//        "3728270502".rand(0,9),
//        "xxxx",
//        "1".rand(0,9),
//        "2".rand(0,9),
//        "3".rand(0,9),
//      );
//}
//echo json_encode($data);
?>
<?php
$_POST['userId']='16';
include "../data/mysql.php";
$result_curent_user = mysql_query("SELECT sim.number
     , user.bonus
     , user.name
     , sum(refill.sum) AS sum
     , user.id
FROM
  sim_owner
INNER JOIN sim
ON sim_owner.sim_id = sim.id
INNER JOIN refill
ON sim_owner.id = refill.sim_owner_id
INNER JOIN user
ON user.id = sim_owner.user_id
WHERE
  sim_owner.state = 1
  AND user.id = ".$_POST['userId']."
GROUP BY
  user.bonus
, sim_owner.user_id
, sim_owner.sim_id
, sim_owner.state
, sim.number
, user.name
, user.id");

echo '<pre>';
while ($row = mysql_fetch_array($result_curent_user, MYSQL_ASSOC)) {
print_r($row);    
}
echo '</pre>';
exit();    
$i=1;
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    $data["aaData"][]=array(
        $i,
        $row['data_prodaji'],
        $row['data_aktivacii'],
        $row['data_zaprosa'],
        $row['summa_popolnenii'],
        $row['tip_popolneniya'],
        $row['nomer_telefona'],
        $row['iccid'],
        $row['chislo_ishodyaschih_zvonkov'],
        $row['chislo_ishodyaschih_min'],
        $row['chislo_vhodyaschih_min']        
      );
      $i++;  
}
echo json_encode($data);
  
?>